package com.yuanian.ecsplus.threadlocal;

import com.yuanian.ecsplus.enums.QueryMode;
import org.springframework.core.NamedThreadLocal;

public  class ThreadLocalEntity<T> {

    private static ThreadLocal object = new NamedThreadLocal<>("threadLocalEntity");

    public static <T> void put(T obj) {
        if (get() == null) {
            object.set(obj);
        }
    }

    public static <T> T get() {
        return (T) object.get();
    }

    public static void clear() {
        object.remove();
    }

    public static void main(String[] args) {
        QueryMode.setMode(QueryMode.HUMP);
       /* new Thread(new Runnable() {
            @Override
            public void run() {
                //String a = ThreadLocalEntity.get();
                System.out.println(ThreadLocalEntity.get().getClass());
            }
        }).start();*/


    }
}
